using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;

namespace PConsulting.DataAccess
{
    public class Project
    {
        private string connectionString;

        public Project()
        {
            connectionString = ConfigurationManager.ConnectionStrings["PConsultingDB"].ConnectionString;
        }

        public DataSet SelectMonths(string userName)
        {
            DataSet ds = SqlHelper.GetDataSet(connectionString, "Project_SelectMonths", new SqlParameter("username", userName));
            return ds;
        }

        public DataSet SelectMonths()
        {
            DataSet ds = SqlHelper.GetDataSet(connectionString, "Project_SelectAllMonths");
            return ds;
        }

        public DataSet SelectById(int projectId)
        {
            DataSet ds = SqlHelper.GetDataSet(connectionString, "Project_SelectById", new SqlParameter("projectId", projectId));
            return ds;
        }

        public DataSet SelectByUserName(string userName)
        {
            DataSet ds = SqlHelper.GetDataSet(connectionString, "Project_SelectByUserName", new SqlParameter("username", userName));
            return ds;
        }

        public DataSet SelectByUserNameMonth(string userName, DateTime month)
        {
            DataSet ds = SqlHelper.GetDataSet(connectionString, "Project_SelectByUserNameMonth", new SqlParameter("username", userName), new SqlParameter("month", month));
            return ds;
        }

        public void Insert(string userName, string client, DateTime startDate, DateTime endDate, string accountManager, string projectResponsible)
        {
            SqlHelper.ExecuteSql(connectionString, "Project_Insert", new SqlParameter("username", userName), new SqlParameter("client", client), new SqlParameter("startdate", startDate), new SqlParameter("enddate", endDate), new SqlParameter("accountmanager", accountManager), new SqlParameter("projectResponsible", projectResponsible));
        }

        public void Update(int projectId, string client, DateTime startDate, DateTime endDate, string accountManager, string projectResponsible)
        {
            SqlHelper.ExecuteSql(connectionString, "Project_Update", new SqlParameter("projectId", projectId), new SqlParameter("client", client), new SqlParameter("startdate", startDate), new SqlParameter("enddate", endDate), new SqlParameter("accountmanager", accountManager), new SqlParameter("projectResponsible", projectResponsible));
        }

        public void Delete(int projectId)
        {
            SqlHelper.ExecuteSql(connectionString, "Project_Delete", new SqlParameter("projectId", projectId));
        }
    }
}
